"""
14、推导式2
1）过滤出长度大于3的人名
name = ['tom','lily','jacks','Pe','Steven']
2）得到嵌套列表中每个列表的最后一个元素
list1 = [[1,2,3],[4,5,6],[7,8,9]]
3）员工工资>5000的人加200，否则加500
dict1 = {'name':'张三','salary':6000}
dict2 = {'name':'李四','salary':8000}
dict3 = {'name':'王五','salary':4000}
dict4 = {'name':'吴二','salary':3000}
list2 = [dict1,dict2,dict3,dict4]
4）找到分数60分以下的人姓名
scores = {
      "Rick Sanchez": 70,
      "Morty Smith": 35,
      "Summer Smith": 82,
      "Jerry Smith": 23,
      "Beth Smith": 98
    }
"""

#1
name = ['tom','lily','jacks','Pe','Steven']
list1=[i for i in name if len(i)<=3]
print(list1)

#2
# list1 = [[1,2,3],[4,5,6],[7,8,9]]
# list2=[i[j] for i in list1 for j in range((len(list1)-1),(len(list1)))]
# print(list2)


list1=[[1,2,3],[4,5,6],[7,8,9]]
list2=[i[:1] for i in list1]
print(list2)

#3
dict1 = {'name':'张三','salary':6000}
dict2 = {'name':'李四','salary':8000}
dict3 = {'name':'王五','salary':4000}
dict4 = {'name':'吴二','salary':3000}
list2 = [dict1,dict2,dict3,dict4]

list3=[(e['name'],e['salary']+200) if e['salary']>500 else e['salary']+500 for e in list2]
print(list3)

#4
scores = {
      "Rick Sanchez": 70,
      "Morty Smith": 35,
      "Summer Smith": 82,
      "Jerry Smith": 23,
      "Beth Smith": 98
    }
list4={k for k,v  in scores.items() if v<60}
print(list4)